﻿using System;
using System.Data;
using System.Linq;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        private void JLTAB05CARD()
        {
            string value = "";
            DataRow dwABP = null;
            DataRow dwWB = null;
           /*exAgent.SetCurrentSheet("JLTAB05CARD");
           DataTable dtABF = dsSource.Tables["ABFOLGE"];*/
            dwABP = dsSource.Tables["ABPOS"].Rows[0];
            dwWB = dsSource.Tables["WBBST"].Rows[0];
            string SRC = ""; double TOT = 0; int ALL = 0;
            /*exAgent.SetCellValue(6, 30, date);
            SRC = dwWB["TP"].ToString().Trim();
            exAgent.SetCellValue(1, 16, SRC);
            SRC = dwABP["ABPART"].ToString().Trim();
            exAgent.SetCellValue(6, 5, SRC);
            SRC = dwABP["ABPFARBE"].ToString().Trim();
            exAgent.SetCellValue(6, 19, SRC);
            
            SRC = dwABP["TYP"].ToString();
            exAgent.SetCellValue(6, 11, Helpers.Helper.GetGB2312Value(SRC).Trim());
            SRC = dwABP["GSCBEZ"].ToString();
            exAgent.SetCellValue(6, 19, Helpers.Helper.GetGB2312Value(SRC).Trim());
            SRC = dwABP["ABPART"].ToString().Trim();
            exAgent.SetCellValue(7, 5, SRC);
            SRC = dwABP["ABPFARBE"].ToString().Trim();
            exAgent.SetCellValue(7, 19, SRC);
            SRC = dwABP["ORDERNO"].ToString().Trim();
            exAgent.SetCellValue(7, 30, SRC);
            SRC = dwABP["QTY"].ToString().Trim();
            exAgent.SetCellValue(8, 5, System.Convert.ToDecimal(SRC));
            SRC = dwABP["BOBIN"].ToString().Trim();
            exAgent.SetCellValue(8, 19, System.Convert.ToDecimal(SRC));
            SRC = dwABP["MACHINE"].ToString().Trim();
            exAgent.SetCellValue(8, 30, SRC);
            SRC = dwABP["METH"].ToString();
            exAgent.SetCellValue(9, 5, Helpers.Helper.GetGB2312Value(SRC).Trim());
            SRC = dwABP["FIN"].ToString();
            exAgent.SetCellValue(9, 14, Helpers.Helper.GetGB2312Value(SRC).Trim());
            SRC = dwABP["BM"].ToString();
            exAgent.SetCellValue(9, 30, Helpers.Helper.GetGB2312Value(SRC).Trim());
            SRC = dwABP["REMARK"].ToString();
            exAgent.SetCellValue(13, 1, Helpers.Helper.GetGB2312Value(SRC).Trim());
            SRC = dwABP["SPART"].ToString();
            exAgent.SetCellValue(13, 26, Helpers.Helper.GetGB2312Value(SRC).Trim());
            
            int x =19 ;
            foreach (DataRow dwABF in dtABF.Rows)
            {                
                SRC = dwABF["ABFAFOLGE"].ToString().Trim().PadRight(6);
                exAgent.SetCellValue(x, 1, SRC);
                SRC = dwABF["STEP"].ToString();
                exAgent.SetCellValue(x, 10, Helpers.Helper.GetGB2312Value(SRC).Trim());
                exAgent.SetCellValue(x+1,1,"1");
                x = x + 2;
            }
            exAgent.RenameSheet("布车卡");
            exAgent.SetCurrentSheet("JLTAB05WB");*/
            int x = 41;
            int i = 1;
            /* exAgent.RangeCopy(41, 42, 43, 45 +2*( dsSource.Tables["WBBST"].Rows.Count/3),true);*/
            foreach (DataRow dwABF in dsSource.Tables["WBBST"].Rows)
            {
               
                SRC = dwABF["WBBSTKNR"].ToString().Trim();
                exAgent.SetCellValue(x, i, SRC);
                SRC =(Convert.ToDouble(dwABF["WBBISTKLG"].ToString())*0.001).ToString();
                exAgent.SetCellValue(x, i+9, SRC);
                x = x + 2;
                 if(x==73)
                {
                    if (i == 1)
                    {
                        i = 13;
                        x = 41;
                    }
                    else
                    {
                        i = 25;
                        x = 41;
                    }
                }
                 TOT += (Convert.ToDouble(dwABF["WBBISTKLG"].ToString()) * 0.001);
            }
            
           
            SRC = (dsSource.Tables["WBBST"].Rows.Count).ToString();
            exAgent.SetCellValue(3, 1, TOT+"米"+"  "+SRC+"卷");
            exAgent.SetCellValue(6, 30, date);
            SRC = dwWB["TP"].ToString().Trim();
            exAgent.SetCellValue(1, 20, SRC);
            SRC = dwABP["ABPART"].ToString().Trim();
            exAgent.SetCellValue(6, 5, SRC);
            SRC = dwABP["ABPFARBE"].ToString().Trim();
            exAgent.SetCellValue(6, 19, SRC);
            exAgent.RenameSheet("布卷信息");
        } 
    }
}